const fs = require('fs');

const getFileStat = function(filePath) {
  return new Promise((resolve, reject) => {
    fs.stat(filePath, (err, stats) => {
      if (err) {
        return reject(err);
      }
      const fileName = filePath.split('\\').slice(-1)[0];
      const fileFolder = filePath.split('\\').slice(0, -1).join('\\');
      
      resolve({...stats, filePath, fileFolder, fileName});
    });
  });
}

module.exports = getFileStat;